package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
public enum SalesOrderGroupReceiveStatusEnum {

    COMPLETED(4, "已完成"),
    WAIT_RECEIVING(13, "待收货"),
    PART_RECEIVING(14, "部分收货");

    private Integer code;
    private String desc;

    SalesOrderGroupReceiveStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static SalesOrderGroupReceiveStatusEnum of(Integer code) {
        return Arrays.stream(SalesOrderGroupReceiveStatusEnum.values()).filter(source -> Objects.equals(code, source.getCode())).findFirst().orElse(null);
    }

    public static List<Integer> codes() {
        return Arrays.stream(SalesOrderGroupReceiveStatusEnum.values()).map(SalesOrderGroupReceiveStatusEnum::getCode).collect(Collectors.toList());
    }
}
